from lib.webui import *
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from hyrobot.common import CHECK_POINT, STEP


class c73311:
    name = '验证退出功能-c73311'  # 测试用例名字

    # 初始化方法
    def setup(self):
        STEP(1, '登陆网站')
        driver = open_browser()
        mgr_login(driver)

    # 清除方法
    def teardown(self):
        driver = get_global_webdriver()
        driver.quit()

    # 测试用例步骤
    def teststeps(self):
        # 获取webdriver对象 对应 已经登录好的浏览器
        driver = get_global_webdriver()
        time.sleep(3)
        # .avatar - wrapper > span
        driver.find_element(By.CSS_SELECTOR,
                            ".avatar-wrapper > span:nth-child(1)").click()

        time.sleep(3)
        logout = driver.find_element(By.CSS_SELECTOR,
                                     "li.el-dropdown-menu__item:nth-child(2) > span:nth-child(1)").click()

        driver.find_element(By.NAME, "username").send_keys("user4")
        driver.find_element(By.NAME, "password").send_keys("123456")
        driver.find_element(By.CSS_SELECTOR, ".el-button").click()

        get_words = driver.find_element(By.CLASS_NAME, "no-redirect").text
        expect_words = "产品列表"
        CHECK_POINT("登录界面标题与预期是否一致", get_words == expect_words)

